//
//  HHAlerViewViewController.m
//  Flower
//
//  Created by 花花 on 2017/1/17.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "HHAlerViewViewController.h"
#import "HHAlertView.h"
@interface HHAlerViewViewController ()
@property (nonatomic,strong)HHAlertView *alertView;

@end

@implementation HHAlerViewViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.titles = @[@"提示+底部两个button",
                    @"提示+底部一个button",
                    @"无提示+底部一个button",
                    @"自定义视图",
                    @"提示+底部Sheet效果",
                    @"有标题自定义输入视图",
                    @"无标题自定义输入视图"];
    
    self.classNames = @[@"HHAlertViewController",
                        @"HHAlertViewController",
                        @"HHAlertViewController",
                        @"HHAlertViewController",
                        @"HHAlertViewController",
                        @"HHAlertViewController",
                        @"HHAlertViewController"];
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    [self showAlertView:indexPath.row];
}
-(void)showAlertView:(NSInteger)row{
    
    if (row == 0) {
        [HHAlertView showTwoButtonsWithTitle:@"信息提示" Message:@"这里为提示的信息内容，里面会根据内容的高度进行计算，当大于弹出窗默认的高度时会自行适应高度(并自动转成UITextView来加载内容这里为提示的信息内容" ButtonType:WJYAlertViewButtonTypeCancel ButtonTitle:@"取消" Click:^{
            NSLog(@"您点取消事件");
        } ButtonType:WJYAlertViewButtonTypeDefault ButtonTitle:@"确定" Click:^{
            NSLog(@"你点确定事件");
        }];
        
    }else if (row == 1){
        [HHAlertView showOneButtonWithTitle:@"温馨提示" Message:@"这里为提示的信息内容，里面会根据内容的高度进行计算，当大于弹出窗默认的高度时会自行适应高度(并自动转成UITextView来加载内容这里为提示的信息内容,你可以单独设置底部每个Button的样式，只要相应枚举进行调整，若不满足可以对针WJYAlertView源代码进行修改" ButtonType:WJYAlertViewButtonTypeNone ButtonTitle:@"取消" Click:^{
            NSLog(@"你点击取消了");
        }];
        
        
    }else if(row == 2){
        
        [HHAlertView showOneButtonWithTitle:nil Message:@"你可以把Title设置为nil" ButtonType:WJYAlertViewButtonTypeNone ButtonTitle:@"知道了" Click:^{
            NSLog(@"响应事件");
        }];
        
        
    }else if (row ==3){
        //自定义视图
        UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 200)];
        customView.backgroundColor = [UIColor blueColor];
        
        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
        [btn setTitle:@"点我关闭" forState:UIControlStateNormal];
        btn.center = CGPointMake(120, 100);
        [customView addSubview:btn];
        [btn addTarget:self action:@selector(closeBtnClick) forControlEvents:UIControlEventTouchUpInside];
        
        // dismissWhenTouchedBackground:NO表示背景蒙层没有关闭弹出窗效果
        _alertView = [[HHAlertView alloc] initWithCustomView:customView dismissWhenTouchedBackground:NO];
        [_alertView show];
        
        
        
    }else if (row ==4){
        
        [HHAlertView showMultipleButtonsWithTitle:@"信息内容" Message:@"可以设置多个的Button,同样也是可以有不同的样式效果" Click:^(NSInteger index) {
            NSLog(@"你点击第几个%zi", index);
        } Buttons:@{@(WJYAlertViewButtonTypeDefault):@"确定"},@{@(WJYAlertViewButtonTypeCancel):@"取消"},@{@(WJYAlertViewButtonTypeWarn):@"知道了"}, nil];
        
    }else{
        
        
        
    }
    
}

-(void)closeBtnClick
{
    // 如果没有其它事件要处理可以直接用下面这样关闭
    // [_alert dismissWithCompletion:nil];
    
    [_alertView dismissWithCompletion:^{
        // 处理内容
        NSLog(@"弹出窗被关闭了");
    }];
}


@end
